﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using ITOMMS.Entity;

namespace ITOMMS.Web.InsideManage
{
    public partial class SmsSendList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataShow(GetSearchSql());

            }
        }

        private void DataShow(string searchSql)
        {
            tbMobileMessageEntity entity = new tbMobileMessageEntity();
            AspNetPager1.RecordCount = entity.GetTotalRecords();
            this.dgdaoim_sus_plyedr.DataSource = entity.GetAllByQuery(searchSql, "order by id desc", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            dgdaoim_sus_plyedr.DataBind();

        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            DataShow(GetSearchSql());
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            DataShow(GetSearchSql());
        }

        private string GetSearchSql()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(" 1=1 ");
            if (txtReceiveMobile.Text.Trim().Length > 0)
            {
                sb.Append(" and  ReceiveMobile like '%").Append(txtReceiveMobile.Text.Trim()).Append("%'"); ;
            }
          
            return sb.ToString();
        }

        protected void btnNew_Click(object sender, EventArgs e)
        {
            Response.Redirect("SmsSend.aspx", true);
        }
    }
}
